home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Scene Storm
/
Scene Storm - Volume 1.iso
/
coding
/
asm
/
music
/
sampleplayers
/
play_samples_irq.s
next >
Wrap
Text File
|
1980-01-03
|
4KB
|
160 lines
custom = $dff000
aud0 = $a0
aud1 = $b0
aud2 = $c0
aud3 = $d0
channel = 16
dmacon = $96
ac_ptr = 0
ac_len = 4
ac_per = 6
ac_vol = 8
DMAF_SETCLR = $8000
section chipmem,code_c
aa cmp.b #100,$dff006
bne.s aa
btst #7,$bfe001
bne.w no_retrig
move.w #$f00,$dff180
lea sample,a0 ;sample data ptr
move.l #sampleend-sample,d0 ;sample length
suba.l a1,a1 ;repeat data ptr
moveq #0,d1 ;repeat length
moveq #0*channel,d2 ;channel number (n x16)
move.w #304,d3 ;sample frequency (note period)
move.w #$40,d4 ;sample volume
bsr notestart
move.w #$bbc,$dff180
ee btst #7,$bfe001
beq.s ee
no_retrig
btst #6,$bfe001
bne.w aa
bb rts
*******************************************************************************
* NoteStart - Start playing a note immediately
* ---------
* $Inputs: a0.l = One-shot sample data
* a1.l = Repeat sample data
* d0.l = One-shot sample length (0 if no one-shot part)
* d1.l = Repeat sample length (0 if no repeat part)
* d2.b = Channel number
* d3.w = Sample frequency (if 0, then high word contains period)
* d4.w = Volume at which to play sample (0-$100)
* $Outputs: None
*******************************************************************************
notestop moveq #0,d0
move.l d0,d1
NoteStart: lea $dff000,a6 * Set the repeat pointers
lea aud0(a6),a5 * $dff0a0 base..
move.w d1,d5 * copy of repeat length
or.w d0,d5 * replen & sample len = 0 ?
bne.s setnote * if so.. turn off note..
moveq #0,d0 * erase d0
bset d2,d0 * set dma bit to turn off dma
move.w d0,dmacon(a6) * turn off channel..
rts
setnote: add.w d2,a5 * channel base $dff0a0/b0/c0/d0
*-------------- check for sample len..
lsr.w #1,d0 * Stuff the one-shot pointers
bne.s hasoneshot
moveq #2,d0 * sample length (set to none)
suba.l a0,a0 * sample data (set to none)
hasoneshot: move.w d3,ac_per(a5) * set period
move.w d4,ac_vol(a5) * set volume
move.l a0,ac_ptr(a5) * set sample data ptr
move.w d0,ac_len(a5) * set sample length
moveq #0,d0 * Turn DMA for this channel off
bset d2,d0
move.w d0,dmacon(a6)
*-------------- check for replen..
lsr.w #1,d1 * do sample repeat?
bne.s hasrepeat
moveq #2,d1 * repeat length (set to none)
suba.l a1,a1 * repeat sample (set to none)
hasrepeat lea dmaflags(pc),a0
or.w d0,(a0) * save sample dma info..
move.b d2,d0
move.w d1,repeatlen-dmaflags(a0,d0.w*2)
move.l a1,repeatptr-dmaflags(a0,d0.w*2)
lea $bfd000,a3
move.b #$7f,$d00(a3)
move.w #$2000,$09c(a6)
move.w #$a000,$09a(a6)
lea mt_irq1(pc),a4
move.l _vbr(pc),a1
move.l a4,$78(a1)
moveq #0,d0
move.b d0,$e00(a3)
move.b #$a8,$400(a3)
move.b d0,$500(a3)
move.b #$11,$e00(a3)
move.b #$81,$d00(a3)
or.w #$8000,dmaflags
rts
mt_irq1 tst.b $bfdd00
move.w dmaflags(pc),$dff096
move.w #$2000,$dff09c
movem.l a0/a1,-(sp)
lea mt_irq2(pc),a0
move.l _vbr(pc),a1
move.l a0,$78(a1)
movem.l (sp)+,a0/a1
rte
mt_irq2 tst.b $bfdd00
movem.l a5-a6,-(sp)
lea $dff000,a6
move.w dmaflags(pc),d0
moveq #1,d1
chan0: lsr.w d1,d0
bcc.s chan1
move.l repeatptr+4*0(pc),aud0+ac_ptr(a6)
move.w repeatlen+2*0(pc),aud0+ac_len(a6)
chan1: lsr.w d1,d0
bcc.s chan2
move.l repeatptr+4*1(pc),aud1+ac_ptr(a6)
move.w repeatlen+2*1(pc),aud1+ac_len(a6)
chan2: lsr.w d1,d0
bcc.s chan3
move.l repeatptr+4*2(pc),aud2+ac_ptr(a6)
move.w repeatlen+2*2(pc),aud2+ac_len(a6)
chan3: lsr.w d1,d0
bcc.s chandone
move.l repeatptr+4*3(pc),aud3+ac_ptr(a6)
move.w repeatlen+2*3(pc),aud3+ac_len(a6)
chandone: clr.w dmaflags
clr.b $bfde00
move.b #$7f,$bfdd00
move.w #$2000,$dff09c
movem.l (a7)+,a5-a6
rte
dmaflags ds.w 1
repeatlen ds.w 4
repeatptr ds.l 4
_vbr ds.l 1
sample incbin 'atro:effects/lasertryr'
sampleend